using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;
using BriansClimb;
using BriansClimb.GameObjects;
using BriansClimb.Climber;
using BriansClimb.DrawableGameObjects.Buttons;
using FarseerGames.FarseerPhysics;
using FarseerGames.FarseerPhysics.Collisions;

namespace BriansClimb.DrawableGameObjects.GameScenes
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class FailureScene : GameScene
    {
        protected Game game;

        protected SpriteBatch spriteBatch;
        
        protected Texture2D background;
        protected Texture2D failureMsg;
        
        //!msgSize controls the size of the message, obviously
        protected int msgSize = 600;        
        protected int messageTimer = 0;


        /// <summary>
        /// Default constructor
        /// Loads the failureMsg texture
        /// </summary>
        /// <param name="game"></param>
        /// <param name="background"></param>
        public FailureScene(Game game, Texture2D background)
            : base(game)
        {
            spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));

            this.background = background;
            this.game = game;
            
            failureMsg = game.Content.Load<Texture2D>(".\\Textures\\failureMsg");
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }       
        
        /// <summary>
        /// Updates the messageTimer which controls how fast the message grows
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            messageTimer++;
            if (messageTimer > 29 && msgSize < 951)
            {
                msgSize = msgSize + 1;
            }                        

            base.Update(gameTime);
        }

        /// <summary>
        /// Draw method
        /// Draws the failureMsg texture to its corresponding size based on the msgSize variable
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Draw(background, new Rectangle(0, 0, 1280, 1024), Color.Black);
                                            
            spriteBatch.Draw(failureMsg, new Rectangle((620 - (msgSize / 2)), (500 - (msgSize / 3)), msgSize, (int)(msgSize / 1.5f)), Color.White);            
            
            base.Draw(gameTime);
        }
    }
}
